//<script type='text/javascript'>

/////// LI FLOAT CLASS

var floats 	= {
	all			: {},
	_proto_		: {
		plus		: function() {
			
			this.vars.action = "edit";
			$( "column_right" ).insert( new Win().request({ type:this.vars.type, action:"edit", vars:this.vars }));
		}
	}
}
		
	
var Float = function ( vars ) {
	
	id = 'float_' + vars.type + '.' + vars.id;

	if($(id)) this.li = $(id);
	else Object.extend( this.li = new Element("li", {id:id, 'class':"float" }), floats.float);
	
	this.li.vars = (vars)? vars : {};
	floats.float.all[id] = this.li;
	
	this.li.extend_by_type().observe( "click", this.li.plus.bind( this.li ));
	this.li.observe( "mouseover", controls.bubble );
	
	return this.li;
}

floats.float	= {
	all		: {},
	objtype	: "float",
	extend_by_type	: function() {
	
		this.insert( this.inc = new Element("div", {'id':this.id+".inc", 'class':"inc" }) );
		this.insert( this.sub = new Element("span", { 'class':"sub" }) );
		this.insert( this.nme = new Element("span", { 'class':"name" }));
		
		this.nme.update( this.vars.list[0] );
		
		switch ( this.vars.type ) {
		case "media.img" :
			this.addClassName( "img" );
			this.inc.setStyle({ background : "url(" + init.url + "/public.img?msk=1&lay=1&id=" + this.vars.list[0] + "&sze=78.20&rand=" + Math.random() + ") no-repeat" });
			this.sub.update( this.vars.list[1] );
			break;
			
		case "media.promo" :
			this.addClassName( "img" );
			this.inc.setStyle({ background : "url(" + init.url + "/public.img?msk=1&lay=1&id=" + this.vars.list[0] + "&sze=78.20&rand=" + Math.random() + ") no-repeat" });
			this.sub.update( this.vars.list[1] );
			break;
		
		case "media.advert" :
			this.addClassName( "img" );
			this.inc.setStyle({ background : "url(" + init.url + "/public.img?msk=1&lay=1&id=" + this.vars.list[0] + "&sze=78.20&rand=" + Math.random() + ") no-repeat" });
			this.sub.update( this.vars.list[1] );
			break;
			
		case "media.stream" :
			this.addClassName( "stream" );
			this.inc.setStyle({ background : "url(" + init.url + "/public.img?msk=1&lay=1&id=" + this.vars.list[0] + "&sze=78.20&rand=" + Math.random() + ") no-repeat" });
			this.sub.update( this.vars.list[1] );
			break;
			
		case "page" :
			
			if( this.addClassName( "drop" ).vars.floats )
				this.inc.setStyle({ backgroundPosition: ((( this.vars.floats.length < 9)? this.vars.floats.length: 8.8 )*10 -88) + "px" });
			
			this.insert( coll = new Dropbox( this.vars ).hide());
			this.inc.observe( "click", coll.toggle.bind( coll ));
			
		default		:
			this.sub.update( this.vars.list[1] );
			break;
		}
		
		return this.nme;
	}
}
Object.extend(floats.float, floats._proto_);



var Li = function ( vars, func ) {
	
	id = 'float_' + vars.type + '.' + vars.id;

	if($( id )) li = $(id);
	else Object.extend( li = new Element("li", {id:id, 'class':"li" }), floats.li );
	
	li.vars = (vars)? vars : {};
	floats.li.all[id] = this.li;
	
	li.observe( "click", ( func )? func : li.plus.bind( this.li )).observe( "mouseover", controls.bubble );
	
	/* if( vars.rank !== undefined )
		li.insert( new Rank({ type: vars.type, value: vars.rank, field:'rank', objid: vars.id }));*/
	
	vars.list.each( function( str ){ li.insert( new Element( "span", { 'class': "node" }).update( str ))});
	

	return li;
}

floats.li	= {
	all		: {},
	objtype	: "float"
}
Object.extend(floats.li, floats._proto_);



var Pair = function ( list, vars ) {

	Object.extend( li = new Element("li", { 'class':"pair" }), floats.pair );
	//li.observe( "mouseover", controls.bubble );
	
	list.each( function( str ){ li.insert( new Element( "input", { type:'text', value: str }).observe( 'change', function(){ this.up(2).update() }))}, li );

	return li;
}

floats.pair	= {
	all		: {},
	objtype	: "pair"
}
Object.extend(floats.li, floats._proto_);

/*

win.trfloat = function(vars) {
	obj = new Element("tr", {id:"float_"+vars.type+"."+vars.id, class:vars.class}).observe("click", (vars.local)? function(){ this.local(); }: function(){ this.plus(); });
	
	if(!vars.local) obj.observe("mouseover", function(){ this.linefloat(); });
	obj.vars = vars;
	
	vars.list.each(function(cell) { obj.appendChild(new Element('td').update((cell!="") ?((typeof cell == "object")?vars[cell.ref]:cell):'&nbsp;')); });
	
	return obj;
}

win.trfloat_methods = {
	linefloat	: function(el) {
		if(win.contr.linefloat.current != el) {
			$("linefloat").clonePosition(el, {setWidth:false, setHeight:true, offsetLeft:el.getWidth()-52, offsetTop:0});
			win.contr.linefloat.current = el;
			$("linefloat").show();
		}
    },
	plus		: function(el) {
		$('column_right').insert( new Win('asset.obj.'+el.vars.type+'.'+el.vars.id).request({tool:el.vars.tool, action:(el.vars.action)? el.vars.action:'edit', vars:el.vars}), {position:'after'});
	},
	local		: function(el) {
		$(el.vars.local+".value").update(el.vars.name);
		Object.extend(el.vars.meta = $(el.vars.local).vars.meta, {value:el.vars.id, field:el.vars.meta.parentfield, objid: el.vars.meta.parentid});
		el.vars.type = el.vars.meta.parenttype;

		xhttp.send('control.call.php', {trg:$(el.vars.local).ancestors()[3].id+".comment", wtype:'push', tool:el.vars.tool, action:'shift', 'vars':el.vars});
	},
	clone		: function(el) {
		
	},
	kill		: function(el) {
		xhttp.send('control.call.php', {trg:el.ancestors()[4].id + ".comment", wtype:'push', tool:el.vars.tool, action:"kill", 'vars':el.vars});
		el.remove();
		//xhttp.send('control.call.php', {trg:vars.id+".comment", wtype:'push', tool:vars.tool, action:"hierarchy", 'vars':vars});
	}
}

Element.addMethods("TR", win.trfloat_methods);


*/



















